/**
 * 一个 Store 的 Module 就是一个包含有 state、getters、mutations、actions、modules 的对象
 */

export default {
  namespaced: true,

  state: () => ({
    // msg: localStorage.getItem("msg") || "~",
    msg: "~",
    count: 1,
  }),

  getters: {
    len(state, getters, rootState, rootGetters) {
      return state.msg.length;
    },
  },

  mutations: {
    change(state, payload) {
      console.log("A change mutation");
    },
    changeMsg(state, payload) {
      state.msg = payload;
      // 做一个存储
      // localStorage.setItem("msg", payload);
    },
  },

  actions: {
    change({ state, getters, rootState, rootGetters }, payload) {
      debugger;
      console.log("A change action");
    },
  },
};
